package com.gegewa.topic.algorithm;

public class SimpleBucketSort {

    public static void main(String[] args) {
        int[] data = new int[] {5, 6, 2, 0, 5};
        sort(data, 10);
    }

    public static void sort(int[] data, int max) {
        int[] bucket = new int[max + 1];
        for (int i = 0, size = data.length; i < size; i++) {
            bucket[data[i]]++;
        }
        for (int i = 0, size = max + 1; i < size; i++) {
            for (int j = 0; j < bucket[i]; j++) {
                System.out.println(i);
            }
        }
    }

}
